package com.shrct.businessprocess.budget.impl;

import com.google.common.base.Objects;
import com.shrct.businessprocess.budget.RCHasCostBudget;
import com.shrct.businessprocess.budget.RCProductDirectCostRequest;
import com.shrct.businessprocess.budget.RCProductDirectCostRequestType;
import com.shrct.businessprocess.budget.impl.RCDirectCostRequestImpl;
import com.shrct.businessprocess.budget.proxy.RCProductDirectCostRequestProxy;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCPRODUCTDIRECTCOSTREQUEST_TYPE")
public class RCProductDirectCostRequestImpl extends RCDirectCostRequestImpl implements RCProductDirectCostRequest {
  public RCProductDirectCostRequestImpl() {
    super();
  }
  
  public RCProductDirectCostRequestImpl(final RCHasCostBudget budget) {
    super( budget);
    
  }
  
  private RCProductDirectCostRequestType requestType;
  
  public RCProductDirectCostRequestType getRequestType() {
    return this.requestType;
  }
  
  public RCProductDirectCostRequest setRequestType(final RCProductDirectCostRequestType requestType) {
    this.requestType = requestType;
    return this;			
    
  }
  
  public String getEntityName() {
    String _xblockexpression = null;
    {
      String _xifexpression = null;
      boolean _equals = Objects.equal(this.requestType, RCProductDirectCostRequestType.product);
      if (_equals) {
        _xifexpression = "\u4EA7\u54C1";
      } else {
        _xifexpression = "\u670D\u52A1";
      }
      final String typeName = _xifexpression;
      RCHasCostBudget _budget = this.getBudget();
      String _entityName = _budget.getEntityName();
      String _plus = (_entityName + ":");
      String _plus_1 = (_plus + typeName);
      String _plus_2 = (_plus_1 + "\u8D39\u7528\u8C03\u6574");
      _xblockexpression = (_plus_2);
    }
    return _xblockexpression;
  }
  
  public static RCProductDirectCostRequest create(final RCHasCostBudget budget, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.budget.RCProductDirectCostRequest rCProductDirectCostRequest = new com.shrct.businessprocess.budget.impl.RCProductDirectCostRequestImpl(
    	budget
    );
    objectFactory.create(rCProductDirectCostRequest);
    return rCProductDirectCostRequest;			
    
  }
  
  public static RCProductDirectCostRequest createRCProductDirectCostRequestImpl(final RCHasCostBudget budget, final IObjectFactory objectFactory, final Procedure1<RCProductDirectCostRequest> init) {
    com.shrct.businessprocess.budget.RCProductDirectCostRequest rCProductDirectCostRequest = new com.shrct.businessprocess.budget.impl.RCProductDirectCostRequestImpl(
    	budget
    );
    objectFactory.create(rCProductDirectCostRequest);
    init.apply(rCProductDirectCostRequest);
    
    return rCProductDirectCostRequest;			
    
  }
  
  public RCProductDirectCostRequestProxy toProxy() {
    com.shrct.businessprocess.budget.proxy.RCProductDirectCostRequestProxy proxy = new com.shrct.businessprocess.budget.proxy.RCProductDirectCostRequestProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
